package ObjectVC;

import java.util.Date;
import javax.swing.JOptionPane;

public class Version {
	private Object object;
	private Class<?> type;
	private Date timestamp;
	private String comment;
	private int index;
	private static int count = 0;
	
	public Version(Object object, Date timestamp, String comment) {
		if (null == object)
			JOptionPane.showMessageDialog(null, "Got null parameters");
		
		this.object = object;
		this.type = object.getClass();
		this.comment = comment;
		this.timestamp = timestamp;
		this.index = count++;
	}
	
	public Version(Object object, String comment) {
		init(object, comment);
	}

	public Version(Object object) {
		init(object, "");
	}
	
	private void init(Object object, String comment) {
		if (null == object)
			JOptionPane.showMessageDialog(null, "Object is null");
		
		this.object = object;
		this.type = object.getClass();
		this.comment = comment;
		this.timestamp = new Date();
	}
		
	Object getObject(){
		return object;
	}
	
	void setObject(Object object){
		this.object = object;
	}
	
	Class<?> getType(){
		return type;
	}
	
	void setType(Class<?> type){
		this.type = type;
	}
	
	Date getTimestamp(){
		return timestamp;
	}
	
	void setTimestamp(Date timestamp){
		this.timestamp = timestamp;
	}
	
	String getComment(){
		return comment;
	}
	
	void setComment(String comment){
		this.comment = comment;
	}

	public int getIndex() {
		return index;
	}
}
